package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zr.service.SavePointService;
@Controller
@Scope(value="prototype")
public class SavePoint implements ServletResponseAware{
	private int pid;
	private String pname;
	private String price;
	private String pclass;
	private int uid;
	private HttpServletResponse resp;
		
	
	
	public String getPclass() {
		return pclass;
	}

	public void setPclass(String pclass) {
		this.pclass = pclass;
	}

	public int getPid() {
		return pid;
	}

	public void setPid(int pid) {
		this.pid = pid;
	}

	public String getPname() {
		return pname;
	}

	public void setPname(String pname) {
		this.pname = pname;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public int getUid() {
		return uid;
	}

	public void setUid(int uid) {
		this.uid = uid;
	}

	@Resource
	private SavePointService savepoint;
	
	public void savepoint(){
		savepoint.savePoint(pid, pname, uid,pclass);
		PrintWriter pw;
		try {
			pw = resp.getWriter();
			pw.write("1");
			pw.flush();
			pw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
		
	@Override
	public void setServletResponse(HttpServletResponse resp) {
			this.resp=resp;
	}
	
}
